package stateselector;

import kruispunt.Kruispunt;

public class State {
	
	private String stateID;
	private int[] greenLights;
	private int priority = 0;
	private Kruispunt kp;
	private int turns = 0;		//Een turn is 15 seconden, dit was de kleins deelbare interval
	
	public State(String stateID, int[] greenLights, Kruispunt kp) {
		this.kp = kp;
		this.stateID = stateID;
		this.greenLights = greenLights;
	}
	
	public int[] getGreenlights() {
		return greenLights;
	}
	
	public void addTurn() {
		turns++;
	}
	
	public int getTurns() {
		return turns;
	}
	
	public int getLength() {
		return greenLights.length;
	}
	
	public int getStatePriority() {
		updatePriority();
		return priority;
	}
	
	public void updatePriority() { //Haalt de baan + zijde prioriteit op 
		int tempPrio = 0;
		for (int i = 0; i < greenLights.length; i++) {
			int baan = greenLights[i];
			tempPrio += kp.getBaanPrioriteit(baan);
		}
		priority = (tempPrio);
	}

	public String getName() {
		return stateID;
	}

	public void resetTurns() {
		turns = 0;
	}

	public void setTurns(int i) {
		turns=i;
	}
}
